package com.library.university.controller;

import com.library.university.Service.UniversityService;
import com.library.university.pojo.University;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class UniversityController {
    @Autowired
    UniversityService universityService;

    @GetMapping("/university")
    public List<University> queryUniversityList(){
        List<University> university = universityService.selectUniversity();
        return university;
    }
    //    添加一个用户
    @PostMapping("/addUniversity")
    public String addUniversity(University university){
        universityService.addUniversity(university);
        return "ok";
    }
    //修改一个用户
    @PutMapping("/updateUniversity")
    public String updateUniversity(University university){
        universityService.updateUniversity(university);
        return "ok";
    }
    //根据ID删除用户
    @DeleteMapping("/deleteUniversity")
    public String deleteUniversity(int id){
        universityService.deleteUniversity(id);
        return "ok";
    }

}
